package cards;

import java.awt.Image;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

/**
 * 
 * @author: CAT
 * 
 */
public class Card implements java.io.Serializable {

	protected int value;
	private String suit;
	private int symbolRank;
	private Image cardImage;
	private boolean faceUp;
	private static Image back;

	/**
	 * Returns boolean indicated if the card is face up or down. Unused method,
	 * may come in handy
	 * 
	 * @return
	 */
	public boolean isFaceUp() {
		return faceUp;
	}

	/**
	 * Returns boolean indicated if the card is face up or down. Unused method,
	 * may come in handy
	 * 
	 * @param faceUp
	 */
	public void setFaceUp(boolean faceUp) {
		this.faceUp = faceUp;
	}

	/**
	 * Contructor for Card
	 * 
	 * @param Value
	 * @param Suit
	 * @param Symbolrank
	 * @param Cardimage
	 * @throws IOException
	 */
	public Card(int Value, String Suit, int Symbolrank, Image Cardimage)
			throws IOException {
		value = Value;
		suit = Suit;
		symbolRank = Symbolrank;
		cardImage = Cardimage;
		faceUp = true;
		back = ImageIO.read(new File("Images\\b1fv.gif"));
	}

	/**
	 * Returns card value
	 * 
	 * @return
	 */
	public int getValue() {
		return value;
	}

	/**
	 * Returns card suit Currently unused may come in handy for future versions.
	 * 
	 * @return
	 */
	public String getSuit() {
		return suit;
	}

	/**
	 * Returns card symbol rank Currently unused may come in handy for future
	 * versions.
	 * 
	 * @return
	 */
	public int getsymbolRank() {
		return symbolRank;
	}

	/**
	 * Returns card image
	 * 
	 * @return
	 */
	public Image getcardImage() {
		if (faceUp) {
			return cardImage;
		} else {
			try {
				return back;
			} catch (Exception e) {
			}
		}
		return cardImage;
	}

	@Override
	public String toString() {
		String cs = "";
		cs = (value + " of " + suit);
		return cs;
	}
}
